#include "QEventViewForm.h"
#include "ui_QEventViewForm.h"
#include <QIcon>
#include <QDebug>

QEventViewForm::QEventViewForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::QEventViewForm)
{
    ui->setupUi(this);
    ui->verticalWidget->setProperty("nav","left");

    QVector<QString> iconfile = {":/image/left_status.png",":/image/left_usb.png",":/image/left.net.png"};
    QList <QToolButton *> toolbtns = ui->verticalWidget->findChildren<QToolButton *>();
    int number = 0;
    foreach(QToolButton * btn , toolbtns)
    {
        QSize size(48, 48);
        btn->setIconSize(size);
        btn->setMinimumHeight(100);
        btn->setMinimumWidth(100);

        QIcon icon;
        icon.addFile(iconfile[number]);
        btn->setIcon(icon);
        btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
        btn->setCheckable(true);

        connect(btn,SIGNAL(clicked()),this,SLOT(navLeftClick()));
        if(number == 0)                         btn->click();
        if(number<iconfile.size()-1)            number++;

    }
}
QEventViewForm::~QEventViewForm()
{
    delete ui;
}

void QEventViewForm::navLeftClick()
{
   QToolButton * btn = (QToolButton *) sender();

   QList<QToolButton *> listBtns = ui->verticalWidget->findChildren<QToolButton *>();
   foreach(QToolButton * btn ,listBtns)
   {
       btn->setChecked(false);
   }
   btn->setChecked(true);
}
